<?php $this->set('title', 'Audience Search'); ?>
<?php $this->set('external_css', array('presenter.css')); ?>
<?php $session->flash();?>
<!-- Survey Results Links -->
<b>Survey Results</b><br />
<?php echo $html->link("Individual", array('controller' => 'presenters', 'action' => 'search_audience')); ?> | 
<?php echo $html->link("Group", array('controller' => 'presenters', 'action' => 'group_results')); ?>
<div class="header">Search Audience Members</div>
<?php echo $this->element('audience_member_search',
	array("controller" => "Presenters", "action" => 'search_audience'));?>
<br />
<?php if($display) { ?>
<!-- Search results -->
<fieldset>
<legend>Search Results</legend>
<table cellpadding="5" cellspacing="0" border="0">
	<tr> 
		<th class="searchColumn"><?php echo $paginator->sort('Username', 'username'); ?></th>
		<th class="searchColumn"><?php echo $paginator->sort('First Name', 'firstname'); ?></th>
		<th class="searchColumn"><?php echo $paginator->sort('Last Name', 'lastname'); ?></th>
		<th class="searchColumn"><?php echo $paginator->sort('Email', 'email'); ?></th>
		<th class="searchColumn" style="color:Blue"><?php echo 'Results'; ?></th>
		<th class="searchColumn">&nbsp;</th>
	</tr>
    <?php foreach($users as $user): ?> 
	<tr>
		<td class="searchColumn"><?php echo $user['User']['username'] ?></td>
		<td class="searchColumn"><?php echo $user['User']['firstname'] ?></td>
		<td class="searchColumn"><?php echo $user['User']['lastname'] ?></td>
		<td class="searchColumn"><?php echo $user['User']['email'] ?></td>
		<td class="searchColumn">
			<?php echo $html->image('chart.gif', array(
		    						'alt' => 'View Results',
									'url' => array('controller' => 'users',
									'action' => 'displayIndividualResults',
									0, $user['User']['id']))); ?>
		</td>
	</tr>
	<?php endforeach; ?>
	<tr>
		<!-- Pagination -->
		<td colspan="3">
			<!-- Shows the next and previous links -->
			<?php
				echo $paginator->prev('« Previous ', null, null, array('class' => 'disabledPageLink'));
				echo $paginator->next(' Next »', null, null, array('class' => 'disabledPageLink'));
			?>
			<br />
			<!-- prints X of Y, where X is current page and Y is number of pages -->
			<?php echo $paginator->counter(); ?>
		</td>
	</tr>
</table>
</fieldset>
<?php } ?>